import pprint
from ConfigParser import ConfigParser

from clutch import Controller, expose

from admin.topes import config_model

class AppAdmin(Controller):

    def __init__(self, instance):
        self.instance = instance
        self.config_file = 'apps/%s.ini' % instance

    @expose()
    def index(self):
        pprint(config_model(self.config))
        return dict()

    def _get_config(self):
        cp = ConfigParser()
        cp.read(self.config_file)
        return cp
    def _set_config(self, cp):
        cp.write(open(self.config_file, 'wb'))
    config = property(_get_config, _set_config)
    


